package com.example.peibei.ui.adapter;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dingtao.common.bean.Order;
import com.dingtao.common.bean.PaiDanList;
import com.dingtao.common.util.GlideUtils;
import com.example.peibei.R;

import java.util.List;

public class PaiDanListAdapter extends BaseQuickAdapter<PaiDanList.RecordsDTO, BaseViewHolder> {

    public PaiDanListAdapter() {
        super(R.layout.item_pai_dan_list);
    }

    @Override
    protected void convert(BaseViewHolder helper, PaiDanList.RecordsDTO item) {
        ImageView head = helper.getView(R.id.iv_head);
        String memberImg = item.getMemberImg();
        helper.setGone(R.id.iv_cert,!item.isRealNameAuth());
        if (memberImg!=null){
            if (memberImg.contains("https://")) {
//                GlideUtils.loadImg(getContext(), memberImg, 20, head);
                Glide.with(getContext()).load(memberImg).apply(RequestOptions.bitmapTransform(new CircleCrop())).into(head);
            } else {
//                GlideUtils.loadImg(getContext(), "https://resource.quqdan.com/" + memberImg, 20, head);
                Glide.with(getContext()).load("https://resource.quqdan.com/" + memberImg).apply(RequestOptions.bitmapTransform(new CircleCrop())).into(head);
            }
        }
        helper.setText(R.id.tv_name, item.getNickname()).setText(R.id.tv_address, "来自于"+item.getArea())
                .setText(R.id.tv_dec, item.getContent()).setText(R.id.tv_cate, item.getCategory())
                .setText(R.id.tv_time, item.getOnline()).setText(R.id.tv_views,item.getVisitCount()+"浏览")
                .setText(R.id.tv_category,item.getApplyCount()+"人已申请");
        if (item.getPrice().contains(".")) {
            String[] split = item.getPrice().split("\\.");
            helper.setText(R.id.tv_price, split[0]);
        } else {
            helper.setText(R.id.tv_price, item.getPrice());
        }
    }
}
